package com.bonc.rms.utils.impl;


import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;



import com.bonc.odk.logmanager.LogManager;
import com.bonc.rms.mapper.WastageInfoUtilMapper;


@Component
public class WastageInfoUtilImpl {

	@Autowired
	WastageInfoUtilMapper wastageInfoUtilMapper;

	/**
	 * 获取离职员工
	 * 
	 * @return
	 */
	public List<String> getLeaveEmployee(Integer departmentStandardId) {
		LogManager.Method("Int Service : WastageInfoUtilImpl -> getLeaveEmployee");
		List<String> employeeList = new ArrayList<>();

		List<Integer> departmentIdlist = new ArrayList<>();
		departmentIdlist = getDepartmentId(departmentStandardId);
		if ((departmentIdlist == null || departmentIdlist.size() == 0)
				&& departmentStandardId > 2) {

		} else {

			employeeList = wastageInfoUtilMapper.getLeaveEmployeeId(
					departmentIdlist, departmentIdlist.size());
		}
		LogManager.Method("Out Service : WastageInfoUtilImpl -> getLeaveEmployee");
		return employeeList;

	}

	/**
	 * 获取离职员工最后一次调薪记录
	 * 
	 * @return
	 */
	public String getRecordSalary(String employeeId) {
		LogManager.Method("Int Service : WastageInfoUtilImpl -> getRecordSalary");
		String ecordSalaryStr = null;

		ecordSalaryStr = wastageInfoUtilMapper
				.getLeaveEmployeeAdjust(employeeId);
		LogManager.Method("Out Service : WastageInfoUtilImpl -> getRecordSalary");
		return ecordSalaryStr;

	}

	/**
	 * 
	 * 获取部门Id
	 */

	public List<Integer> getDepartmentId(Integer departmentId) {
		LogManager.Method("Int Service : WastageInfoUtilImpl -> getDepartmentId");
		List<Integer> list = new ArrayList<>();
		list = wastageInfoUtilMapper.getDepartmentId(departmentId);
		LogManager.Method("Out Service : WastageInfoUtilImpl -> getDepartmentId");	
		return list;

	}

	/**
	 * 
	 * list转String
	 */
	public static StringBuffer stringUtil(List<Integer> list) {
		LogManager.Method("Int Service : WastageInfoUtilImpl -> stringUtil");
		StringBuffer str = new StringBuffer();
		str.append("(");
		for (Integer integer : list) {
			str.append(integer + ",");
		}
		str.append(")");
		LogManager.Method("Out Service : WastageInfoUtilImpl -> stringUtil");
		return str.deleteCharAt(str.length() - 2);

	}
}
